import 'package:flutter/material.dart';
import 'package:tiktokadult/hj_utils/widget_utils.dart';
import 'package:tiktokadult/tools_base/widget/keep_alive_widget.dart';

import 'follow_topic_list_view.dart';
import 'follow_user_list_view.dart';
import 'follow_video_list_view.dart';

class HomeFollowPage extends StatefulWidget {
  final int index;

  const HomeFollowPage(this.index, {Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _HomeFollowPageState();
  }
}

class _HomeFollowPageState extends State<HomeFollowPage> with TickerProviderStateMixin{

  late TabController tabController;
  List<String> get titleArr => ["视频","UP主","分类"];
  @override
  void initState() {
    super.initState();
    tabController = TabController(initialIndex: 0, length: titleArr.length, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        TabBar(
          tabAlignment: TabAlignment.center,
          tabs: titleArr.map((e) => Container(
            padding: EdgeInsets.symmetric(horizontal: 12),
            alignment: Alignment.center,
            child: Text(e),
          ))
              .toList(),
          isScrollable: true,
          padding: EdgeInsets.only(bottom: 6),
          labelPadding: EdgeInsets.zero,
          unselectedLabelStyle: TextStyle(fontSize: 14),
          unselectedLabelColor: Color(0x8CFFFFFF),
          labelStyle: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
          labelColor: Color(0xE5FFFFFF),
          indicator: BoxDecoration(),
          controller: tabController,
        ),
        12.sizeBoxH,
        Expanded(
          child: TabBarView(
            controller: tabController,
            children: [
              FollowVideoListView().keepAlive,
              FollowUserListView().keepAlive,
              FollowTopicListView().keepAlive,
            ],
          ),
        ),
      ],
    );
  }
}
